﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiPort.TiEntityObjects;
using System.Xml.Serialization;
using TI;
using TiEntityObject.Notification;
using TiEntityObject.Common;

namespace TiEntityObject.Notification
{
    public class NotificationLot 
    {
        public Int64 NotificationID { get; set; }

        [XmlElement("sid")]
        public long Sid { get; set;}

        [XmlElement("ordinalNumber")]
        public string OrdinalNumber { get; set;}

        [XmlElement("subject")]
        public string Subject { get; set; }

        [XmlElement("currency")]
        [LinkObjectAttribute(ChildFieldName = "code", IsDictionaryValue = true, ParentFieldName = "CurrencyID")]
        public Currency Currency { get; set; }

        public string CurrencyID { get; set; }

        [XmlElement("products")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public Products Products { get; set; }


        [XmlElement("auctionProducts")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public NotificationLotAuctionProducts AuctionProducts { get; set; }


        [XmlElement("notificationFeatures")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public NotificationFeatures NotificationFeatures { get; set; }


        [XmlElement("customerRequirements")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public NotificationCustomerRecuirements CustomerRecuirements { get; set; }

        [XmlElement("priceNotSet")]
        public string priceNotSet { get; set; }

        [XmlElement("energyService")]
        public NotificationEnergyService NotificationEnergyService { get; set; }

        public decimal LotMaxPrice {
            get {
                decimal result = 0;
                if (this.CustomerRecuirements == null)
                    return result;

                foreach (NotificationCustomerRecuirement r in this.CustomerRecuirements.CustomerRequirementList)
                {
                    result = r.dMaxPrice;
                }
                return result;
            }
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        [XmlElement("auctionItems")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public NotificationAuctionItems AuctionItems { get; set; }

        [XmlElement("documentRequirements")]
        [LinkObjectAttribute(ChildFieldName = "LotSid", IsCollection = true, IsPartialObject = true, ParentFieldName = "Sid")]
        public NotificationDocumentRequirements NotificationDocumentRequirements { get; set; }        

    }
}
